This lab will illustrate how to use RMarkdown to create reproducible analyses.
Data-driven documents are formats that combine text and analysis (i.e. data and code). By combining everything in a single file, we promote transparency and reproducibility. For any given table, figure, or model in the document, you should be able to easily discern how it was created, from what data, and what analysis was used.
We will use the R Markdown format.
All of the document formats build from a simple text formatting convention called markdown.
To create an R Markdown document, you need three things:
Markdown is a simple set of rules used to format text. It has been adopted broadly by the data science community and is used on GitHub, Stackoverflow, and now in R Studio.
To give just a couple of examples of how it works:
Unordered Lists
* First item
* Second item
* Third item
* First nested item
* Second nested item
Hyperlinks
Create links by wrapping the link text in square brackets [ ], and the URL in adjacent parentheses ( ).
I find that [Google News](https://news.google.com) over-curates my media diet.
I find that Google News over-curates my media diet.
Tables
| Title 1 | Title 2 |
|------------------|------------------|
| First entry | Second entry |
| Third entry | Fourth entry |
| Fifth entry | Sixth entry |
| Title 1 | Title 2 |
|---|---|
| First entry | Second entry |
| Third entry | Fourth entry |
| Fifth entry | Sixth entry |
You can see a full list of markdown rules HERE.
Code is placed inside of “chunks” in the documents:
When you “knit” a file R Studio will run all of code, embed the output into your document, and then convert the file to whichever type you have specified in the file header.

You can select from many different document types, including HTML pages, Microsoft word, presentation formats, or dashboards.
Check out these examples:
R Markdown
Formats
R Markdown
Gallery